package com.lanou.controller;

import com.lanou.entity.Charity;
import com.lanou.service.CharityService;
import com.lanou.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName Charity
 * @Description TODO
 * @Author lizhenjiang
 * @Date 2025年08月13日 17:28
 * @Version 1.0
 */
@RestController
@RequestMapping("charity")
public class CharityController {
    @Autowired
    private CharityService charityService;

    @GetMapping("{id}")
    public R getCharityById(@PathVariable Integer id) {
        return R.ok(charityService.getCharity(id));
    }

    @GetMapping("getPages")
    public R getCharityList(Charity charity, @RequestParam(value = "pageNum",defaultValue = "1",required = false) Integer pageNum, @RequestParam(value = "pageSize",defaultValue = "10",required = false) Integer pageSize) {
        return R.ok(charityService.getCharitys(charity,pageNum,pageSize));
    }
}
